package com.xiang.sql.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.xiang.api.Util;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 代金券 数据实体
 * 
 * @author mac-xiang
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "`voucher`", autoResultMap = true)
@ApiModel(value = "代金券 对象", description = "代金券")
public class Voucher implements Serializable {

  private static final long serialVersionUID = 1L;
  /** 主键ID */
  @TableId(value = "id", type = IdType.ASSIGN_ID)
  public String id;

  /** 创建时间 */
  @TableField(value = "`create_time`", fill = FieldFill.INSERT)
  public Long createTime;
  /** 使用时间 */
  @TableField(value = "`change_time`", fill = FieldFill.INSERT)
  public Long changeTime;

  /** 创建用户 */
  @TableField(value = "`create`", fill = FieldFill.INSERT)
  public String create;

  /** 名称 */
  @TableField(value = "`name`", fill = FieldFill.INSERT)
  public String name;

  /** 金额 */
  @TableField(value = "`money`", fill = FieldFill.INSERT)
  public Integer money;

  /** 使用人id */
  @TableField(value = "`use`", fill = FieldFill.INSERT)
  public String use;
  /** 图片URL */
  @TableField(value = "`image`", fill = FieldFill.INSERT)
  public String image;

  public Voucher() {
  }

  public Voucher(long time, String create, String name, int money, String image) {
    this.id = Util.sGetId();
    this.changeTime = 0l;
    this.createTime = time;
    this.create = create;
    this.name = Util.isEmpty(name) ? "" : name;
    this.money = !(money > 0) ? 0 : money;
    this.image = Util.isEmpty(image) ? "" : image;
    this.use = "";
  }
}